package com.luoqiz.designPatterns.util;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class XMLUtil {
	public static String getSimpleFactoryOperationType() {
        SAXReader reader = new SAXReader();
        String operationType = "";
        try {
			Document document = reader.read("src/main/java/com/luoqiz/designPatterns/config/config.xml");
			Element rootElement = document.getRootElement();
			Element node = rootElement.element("simpleFactory");
			operationType = node.getStringValue();
		} catch (DocumentException e) {
			e.printStackTrace();
		}
        return operationType;
	}
	public static String getLoggerFactoryClass() {
		SAXReader reader = new SAXReader();
		String operationType = "";
		try {
			Document document = reader.read("src/main/java/com/luoqiz/designPatterns/config/config.xml");
			Element rootElement = document.getRootElement();
			Element node = rootElement.element("loggerFactoryClass");
			operationType = node.getStringValue();
		} catch (DocumentException e) {
			e.printStackTrace();
		}
		return operationType;
	}
	public static void main(String[] args) {
		String opt = XMLUtil.getSimpleFactoryOperationType();
		System.out.println(opt);
	}
}
